const express = require('express');
const mysql      = require('mysql');
const config = require('./config/config.js');
const connection = mysql.createPool(config.mysql);
const bodyParser = require('body-parser');
const multer = require('multer');
const cookieParser = require('cookie-parser');
const session = require('express-session');

const app = express();
app.listen(8081);
//1.解析cookie
app.use(cookieParser('sdfasl43kjoifguokn4lkhoifo4k3'));

//2.使用session
var arr=[];
for(var i=0;i<100000;i++){
    arr.push('keys_'+Math.random());
}
//server.use(cookieSession({name: 'fes_session_id', keys: arr, maxAge: 20*3600*1000}));
app.use(session({
    secret: arr,
    resave: false,
    name: 'fes_session_id',
    saveUninitialized: true,
    maxAge: 20*3600*1000
}))
//3.post数据
app.use(bodyParser.urlencoded({extended: false}));
app.use(multer({dest: './upload'}).any());

//4.静态数据
app.use('/',express.static(__dirname+'/dist'));

app.use('/login', require('./router/login'));